<%@ page isELIgnored="false" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>车享乐-订单信息</title>
	<link rel="stylesheet" type="text/css" href="/static/css/reset.css">
	<link rel="stylesheet" type="text/css" href="/static/css/main.css">
	<script type="text/javascript" src="/static/js/jquery-1.12.4.min.js"></script>
	<script type="text/javascript" src="/static/js/jquery-ui.min.js"></script>
	<script type="text/javascript" src="/static/js/slide.js"></script>
	<script type="text/javascript" src="../../static/layui/layui.js"></script>
	<link href="../../static/layui/css/layui.css" rel="stylesheet" rel="stylesheet">
	<script src="../../static/mylayer.js" type="text/javascript" charset="utf-8"></script>
	<style>
		.avatar-img {
			width: 20px; /* 设置头像图片的宽度 */
			height: 20px; /* 设置头像图片的高度，可以根据需要调整 */
			border-radius: 50%; /* 使图片呈现圆形 */
			margin-right: 10px; /* 设置头像图片与用户名之间的间距，可以根据需要调整 */
		}
		#damageDescription {
			width: 1000px;
		}


	</style>
</head>
<body>
	<div class="header_con">
		<div class="header">
			<div class="welcome fl">欢迎来到鑫鑫车享乐租车系统!  祝您畅享旅途，鑫鑫相伴！</div>
			<div class="fr">
				<div class="user_link fl">
					<a href="javascript:;">
						欢迎您：<img class="avatar-img" src="/pic/${user.avatar}"/>
						${user.username}
					</a>
					<span>|</span>
					<a href="/page/user/info">用户中心</a>
					<span>|</span>
					<a href="/page/user/order">我的订单</a>
					<span>|</span>
					<a href="javascript:logout()">注销</a>
				</div>
			</div>
		</div>
	</div>

	<div class="search_bar clearfix">
		<a href="/" class="logo fl"><img src="/static/pic/xx-logo.png" width="180%"></a>
		<div class="search_con fr">
			<input type="text" id="searchInput" class="input_text fl" placeholder="搜索商品">
			<input type="button" id="searchButton" class="input_btn fr" value="搜索">
		</div>
	</div>




	<h3 class="common_title">订单信息</h3>

	<div class="common_list_con clearfix">
		<table class="layui-table">
			<thead>
			<tr>
				<th>订单编号</th>
				<th>汽车照片</th>
				<th>汽车型号</th>
				<th>汽车车牌</th>
				<th>租赁开始时间</th>
				<th>租赁结束时间</th>
				<th>订单费用</th>
				<th>下单时间</th>
			</tr>
			</thead>
			<tbody>
			<tr id="Order">

			</tr>
			</tbody>
		</table>
	</div>

	<div id="Rent_List">

	</div>


	<div class="footer">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888    京ICP备*******8号</p>
	</div>


	<script type="text/javascript">
		$('#searchButton').click(function() {
			var searchText = $('#searchInput').val(); // 获取搜索框中的值
			var searchUrl = '/page/car/list?search=' + encodeURIComponent(searchText); // 构建带有搜索关键字的URL
			window.location.href = searchUrl; // 跳转到另一个页面
		});
		var queryString = window.location.search;
		var urlParams = new URLSearchParams(queryString);
		var id = urlParams.get("id");
		var orderStatus = urlParams.get("orderStatus");
		$.post(
				'/order?method=selectById',
				{'id':id},
				function (result) {
					if (result.code == 0) {
						var html = ''
						$('#Order').empty();
						$(result.data).each(function () {
							html += '<td>'+this.orderNumber+'</td>'
							html += '<td><img src="/pic/'+this.image+'"></td>'
							html += '<td>'+this.model+'</td>'
							html += '<td>'+this.licensePlate+'</td>'
							html += '<td>'+this.rentalStartDate+'</td>'
							html += '<td>'+this.rentalEndDate+'</td>'
							html += '<td>'+this.totalCost+'元</td>'
							html += '<td>'+this.orderTime+'</td>'
						}),
						$('#Order').append(html);
					}
				},
				'json'
		);
		$.post(
				'/return?method=selectByRentId',
				{'rentalId':id},
				function (result) {
					if (result.code == 0) {
						var html = ''
						$('#Rent_List').empty();
						$(result.data).each(function () {
							if (orderStatus == 0) {
								html += '<h3 class="common_title">还车</h3>'

								html += '<div class="common_list_con clearfix">'
								html += '	<br><br>'
								html += '		<div class="layui-form-item layui-form-text">'
								html += '			<label class="layui-form-label">损坏描述</label>'
								html += '			<div class="layui-input-block" >'
								html += '				<textarea placeholder="'+this.damageDescription+'" class="layui-textarea" id="damageDescription" disabled></textarea>'
								html += '			</div>'
								html += '		</div>'
								html += '</div>'
							}

						}),
						$('#Rent_List').append(html);
					}
				},
				'json'
		);
		function logout() {
			layer.confirm(
					'您确认要退出么',
					{icon:3},
					function() {
						$.post(
								'/user?method=logout',
								function (result) {
									if (result.code == 0) {
										mylayer.okUrl(result.msg, '/page/login');
									}
								},
								'json'
						);
						// location.href = '/admin?method=logout'
					}
			);
		}
	</script>
</body>
</html>